<template>
  <div>
    <detail-header></detail-header>
    <detail-swiper :imgs="swipwepic"></detail-swiper>
    <detail-content :text1="goodstex" :desc1="goodsdesc" :price1="goodspirce"></detail-content>
  </div>
</template>

<script>
import DetailHeader from './components/Header'
import DetailSwiper from './components/Swiper'
import DetailContent from './components/Content'
import axios from 'axios'
export default {
  name: 'Detail',
  data () {
    return {
      swipwepic: [],
      goodstex: '',
      goodsdesc: '',
      goodspirce: ''
    }
  },
  components: {
    DetailHeader,
    DetailSwiper,
    DetailContent
  },
  methods: {
    getDetailInfo (a) {
      axios.get('/api/detail' + a + '.json').then(this.handleGetInfo)
    },
    handleGetInfo (res) {
      // console.log(res)
      var data = res.data
      if (data.ret === true) {
        this.swipwepic = data.data.imgs
        this.goodstex = data.data.text
        this.goodsdesc = data.data.desc
        this.goodspirce = data.data.price
        // console.log(typeof data.data[0].imgs)
      }
    }
  },
  mounted () {
    this.getDetailInfo(this.$route.params.id)
  }
}
</script>

<style>

</style>
